{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%html\n",
    "<!-- （勿改动，执行即可）执行更改背景 -->\n",
    "<link rel=\"stylesheet\" href=\"exam.css\" type=\"text/css\">\n",
    "<h1 style=\"color: red;\">注意单元格的第一行不能改动，否则会影响自动打分</h1>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 始000（勿改动，执行即可）\n",
    "e = %env\n",
    "_which_= \"C\"  # 卷号\n",
    "import PandasCourse as PC\n",
    "from IPython.display import Markdown\n",
    "Markdown(PC.msgs['opening'].format(w=_which_))   "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 始001（✍请改动並执行）\n",
    "student_id = \"\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 读入数据\n",
    "* 以下代码是读入相关文本数据\n",
    "* 所有文本数据赋值给text\n",
    "* 以下考题皆为针对此text做相关操作"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 直接执行，执行完请观察text文本\n",
    "import pandas as pd\n",
    "df = pd.read_csv('Combined_374.csv','\\t')\n",
    "df_summary = df[\"AB\"].fillna(\"NAN\").tolist()\n",
    "text = \"\".join(df_summary) "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Q1（20分） 🌶 易\n",
    "* 查找\"媒体\"的次数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 请勿改动变量名freq_table_phrase，过程可自行书写\n",
    "phrase = \n",
    "freq_table_phrase=\n",
    "freq_table_phrase"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Q2（20分） 🌶 易\n",
    "* 用中文\"。\"拆分,生成list_split列表，每一个句子是一个独立的列表元素"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 请勿改动变量名list_split，过程可自行书写\n",
    "list_split =\n",
    "list_split"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Q3 （20分） 🌶 易\n",
    "* 取出第十个句子"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 请勿改动变量名the_10_phrase，过程可自行书写\n",
    "the_10_phrase=\n",
    "the_10_phrase"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Q4 （40分） 🌶🌶  中\n",
    "* 请找出text中所有\"媒体\"关键字前面的两个字符\n",
    "\n",
    "> 1. 先找出所有新媒体位置**列表** position_all，（20分）\n",
    "> 2. 再找出所有 \"媒体\"关键字前面的两个字符**列表**  content_all，（20分）"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "```\n",
    "答案提示:\n",
    "[95, 144, 154, 164, 204, 235, 356, 400, ...]\n",
    "['提出', '应新', '重新', '用新', '建新', ...]\n",
    "\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 请勿改动变量名position_all，content_all，过程可自行书写\n",
    "phrase=\n",
    "\n",
    "position_all=[] # \"媒体\"  出现的位置\n",
    "\n",
    "\n",
    "\n",
    "print(position_all) \n",
    "\n",
    "content_all=[]\n",
    "    \n",
    "    \n",
    "    \n",
    "print(content_all)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Q5 （20分） 🌶🌶  中\n",
    "* 统计text中所有\"媒体\"关键字前面的两个字符的出现次数（即词频）\n",
    "\n",
    "```\n",
    "答案示例：\n",
    "{'提出': 2, '应新': 3, '重新': 1, '用新': 3, '建新': 1,...}\n",
    "\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 请勿改动变量名found，过程可自行书写\n",
    "found = {}\n",
    "\n",
    "print(found)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Q6 （20分） 🌶 🌶 🌶 稍难\n",
    "* 找出text中所有\"媒体\"关键字前面的两个字符的次数排在前八的关键词，作为一个新的字典输出"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 请勿改动变量名top8_found，过程可自行书写\n",
    "top8_found = {}\n",
    "\n",
    "top8_found"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 🙌🙌🙌🎈 👍 恭喜 👍 🎉🙌🙌🙌\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 🏁🏁🏁回报答题分数（仅供参考）🏁🏁🏁"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#终001 （勿改动，执行即可）回报答题分数\n",
    "import PandasCourse as PC\n",
    "\n",
    "score_details = PC.score_answers(locals(), _which_)\n",
    "print (score_details[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
